

package cn.shengchao.examstar.comment.acl.ports.repositories.message;

import cn.hutool.core.date.DateUtil;
import cn.shengchao.examstar.comment.infrastructure.dao.po.TProductComment;
import lombok.Data;

@Data
public class CommentListDto {
    private String content;
    private String studentName;
    private String studentHeadImg;
    private Double score;
    private String createTime;
    private Boolean anonymity;

    public static CommentListDto of(TProductComment tProductComment) {
        CommentListDto commentListDto = new CommentListDto();
        commentListDto.setContent(tProductComment.getContent());
        if (tProductComment.getAnonymity()) {
            commentListDto.setAnonymity(true);
        } else {
            commentListDto.setStudentName(tProductComment.getStudentName());
            commentListDto.setStudentHeadImg(tProductComment.getStudentHeadUrl());
        }
        commentListDto.setScore(tProductComment.getScore());
        commentListDto.setCreateTime(DateUtil.format(tProductComment.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
        return commentListDto;
    }
}
